<template>
	<view class="content">
		<view class="header">
			<view class="ipt-box">
				<input v-model="village" type="text" value="" placeholder="请输入您要找的镇子名称" placeholder-class="plac-class" />
				<image src="/static/search1.png" mode="" @click="villageSearch"></image>
			</view>
			<view class="header-right" @click="village = ''">
				<span>取消</span>
			</view>
		</view>
		<!-- village -->
		<view class="village-box">
			<view class="village-item" v-for="(item,index) in villageList" :key="index" @tap="checkRepq(item.id)">
				<view class="village-item-left">
					<view class="shuxian"></view>
					<view class="adress-box">
						<view class="adress">{{item.name}}</view>
						<!-- <view class="adressPosini">{{item.village_count}}</view> -->
					</view>
				</view>
				<view class="village-item-right">
					<view class="huhao">查看</view>
				</view>
			</view>
			<view class="nomodel" v-if="villageList.length==0">
				<u-empty  text="暂无内容"  mode="list"></u-empty>
			</view>
		</view>
	</view>
</template>

<script> 
	export default { 
		data() {
			return {
				username: '',
				password: '',
				// array: ['安装工','检测工','维修工'],
				index: 0,
				userinfo:{},
				value:'',  //搜索关键词
				installList:[],  //安装列表
				dosearch:false,
				showAcount:false,
				page:1,
				villageList:[],
				active:0,
				token:'',
				totwn: 0,
				village: ''
			};
		},
		onLoad() {
		 
		},
		onShow() {
			uni.getStorage({
				key: 'token'
			}).then(da => {
				this.token = da[1].data
			})
			setTimeout(() => {
				this.getInstallDetail()
			},10)
		},
		//下拉刷新
		onPullDownRefresh(){
			this.page=1
			 setTimeout(function() {
			 	uni.stopPullDownRefresh();
			 }, 500);
			// this.getInstallDetail()
		},
		onReachBottom() {
			this.page++
			if(this.page >= this.totwn) {
				uni.showToast({
					title: '已经到底了',
					icon: 'none'
				})
				return
			}
			this.getInstallDetail()
		},
		watch:{
			village(e) {
				if(!e) {
					this.getInstallDetail()
				}
			}
		},
		methods: {
			// 获取安装数据
			getInstallDetail () {
				let that = this
				that.$request.request({
					url: 'equipment/township_list',
					method: 'POST',
					data: {
						token: that.token,
						page: that.page,
						keyword:that.village
					}
				}).then(res => {
					if(res.data.code == 1) {
						that.villageList = res.data.data.list
						that.totwn = res.data.data.page_count
					}
				})
			 },
			 villageSearch() {
				 this.villageList = []
				 if(this.village == '') {
					 uni.showToast({
					 	title: '请输入您要找的村子',
						icon: 'none'
					 })
					 return
				 }
				 this.getInstallDetail()
			 },
			 checkRepq(id) {
				 uni.navigateTo({
				 	url: '/pagesB/repairchilder/repairchilder?id=' + id
				 })
			 },
			 back() {
				 uni.navigateTo({
				 	url: '../index/index'
				 })
			 }
		},
		
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #F5F5F5;
		// padding-bottom: 200upx;
		// margin-bottom: 150upx;
	}
	.content{
		padding-bottom: 140upx;
	}
	.shuxian{
		width: 8upx;
		height: 28upx;
		background-color: #003690;
		border-radius: 8upx;
		margin-right: 20upx;
	}
	.header1{
		display: flex;
		justify-content:space-between;
		align-items: center;
		padding: 30upx 30upx;
		background-color: #fff;
		.header-left{
			display: flex;
			align-items: center;
			font-size: 32upx;
			font-weight: 500;
			color: #333;
			image{
				width: 24upx;
				height: 24upx;
				margin-right: 20upx;
			}
		}
		.header-right{
			display: flex;
			align-items: center;
			font-size: 24upx;
			color: #333;
			image{
				width: 52upx;
				height: 52upx;
				margin-right: 10upx;
			}
		}
	}
	.header{
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		height: 80upx;
		width: 100%;
		background-color: #003690;
		padding: 0 40upx;
		.ipt-box{
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 0 20upx;
			width: 514upx;
			height: 52upx;
			background-color: #fff;
			border-radius: 24upx;
			image{
				width: 32upx;
				height: 32upx;
			}
		}
		.header-right{
			display: flex;
			align-items: center;
			font-size: 32upx;
			color: #E2ECFB;
			image{
				width: 36upx;
				height: 36upx;
			}
		}
	}
	.test-code:active{
		background: rgba(69, 82, 202, 0.4);
		color: #fff;
	}
	.plac-class{
		font-size: 32upx;
		color: #999;
	}
	// nav
	.nav{
		width: 100%;
		height: 80upx;
		background-color: #fff;
		.nav-box{
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 50%;
			margin: 0 auto;
			line-height: 76upx;
			span{
				padding: 0 10upx;
				font-size: 32upx;
				color: #333;
				border-bottom: 4upx solid transparent;
			}
			.current{
				color: #003690;
				border-bottom: 4upx solid #003690;
			}
		}
	}
	// danger
	.village-item{
		position: relative;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		width: 690upx;
		padding:20upx 30upx;
		background-color: #fff;
		border-radius: 10upx;
		margin: 20upx auto 0;
		box-shadow:0px 3px 4px rgba(0,30,57,0.15);
		.flag{
			position: absolute;
			right: 0;
			top: 0;
			width: 64upx;
			height: 64upx;
		}
		.village-item-left{
			display: flex;
			align-items: center;
			.adress-box{
				display: flex;
				align-items: center;
				position: relative;
				.shuxian{
					width: 8upx;
					height: 28upx;
					background-color: #003690;
					border-radius: 8upx;
					margin-right: 20upx;
				}
				.adress{
					font-size: 32upx;
					color: #333;
				}
				.adressPosini{
					position: absolute;
					top: -10upx;
					right: -30upx;
					width: 44upx;
					height: 32upx;
					background-color: #d10000;
					opacity: 0.56;
					color: #fff;
					border-radius: 20upx;
					text-align: center;
					line-height: 32upx;
					font-size: 24upx;
				}
			}
			.time{
				display: flex;
				align-items: center;
				font-size: 24upx;
				color: #777;
				image{
					width: 28upx;
					height: 28upx;
					margin-right: 10upx;
				}
			}
			
		}
		.village-item-right{
			display: flex;
			align-items: center;
			.huhao{
				width: 100upx;
				height: 48upx;
				border: 2upx solid #003690;
				border-radius: 24upx;
				font-size: 28upx;
				color: #003690;
				margin-right: 30upx;
				text-align: center;
			}
			.huhao1{
				width: 94upx;
				height: 46upx;
				border: 2upx solid #dddddd;
				border-radius: 16upx;
				font-size: 28upx;
				color: #dddddd;
				margin-right: 30upx;
				text-align: center;
			}
		}
	}
</style>
